<template>
	<view>
		<uNavbar title="我的权益"></uNavbar>
		<view class="user mart flex_dq">
			<view class="user_l flex_c">
				<image :src="userinfo.head_img" mode="aspectFill"></image>
			</view>
			<view class="user_c flex_Z">
				<view class="user_c_name flex_dq">
					<text class="f30 c0">{{userinfo.nickname}}</text>
					<text class="f24 c4">{{userinfo.phone_format}}</text>
				</view>
				<text  class="f26 c4">用户身份：{{identityAll.name}}</text>
			</view>
		</view>
		<view class="blockchain flex_dq">
			<view class="blockchain_box ">
				<text>区块链地址:</text>
				<text>{{userinfo.eth_address}}</text>
			</view>
			<image src="../../static/icon/copy3.png" mode="aspectFill" @click="isCopy"></image>
		</view>
		<view class=" flex_Z">
			<view class="income_box flex_dq">
				<text>福合通宝总收益</text>
				<text>￥{{memberAttach.balance_income_price}}</text>
			</view>
			<view class="income_box flex_dq">
				<text>FH原石总收益</text>
				<text>￥{{memberAttach.balance_hf_income_price}}</text>
			</view>
		</view>

		<view class="recommendation flex_Z">
			<view class="navtab flex_ld_b">
				<text :class="inx == '1' ?'active':''" data-type="1" @click="istaggle">福合通宝收益</text>
				<text :class="inx == '2' ?'active':''" data-type="2" @click="istaggle">FH原石收益</text>
			</view>
			<view  v-if="inx == 1" >
				<view v-for="(item,index) in fhtbList" :key="item.id">
					<view class="income_list">
						<view class="income_list_box flex_ld">
							<view class=" flex_ld">
								<text class="c4 f28">收益金额：</text>
								<text class="c0 f28">{{item.amount}}</text>
							</view>
							<text class="c4 f28">{{item.create_time}}</text>
						</view>
						<view class="income_list_box flex_ld">
							<view class="flex_ld">
								<text class="c4 f28">备注：</text>
								<text class="c0 f24"> {{item.remark}}</text>
							</view>
						</view>
					</view>
				</view>
				<noDatas :xxxList="fhtbList" :status="status"></noDatas>
			</view>

		<view  v-else >
			<view v-for="(item,index) in FHList" :key="item.id">
				<view class="income_list">
					<view class="income_list_box flex_ld">
						<view class=" flex_ld">
							<text class="c4 f28">收益金额：</text>
							<text class="c0 f28">{{item.amount}}</text>
						</view>
						<text class="c4 f28">{{item.create_time}}</text>
					</view>
					<view class="income_list_box flex_ld">
						<view class="">
							<text class="c4 f28">备注：</text>
							<text class="c0 f24"> {{item.remark}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 暂无数据 / 加载更多 -->
			<noDatas :xxxList="FHList" :status="status"></noDatas>
		</view>
		</view>
	</view>
</template>

<script>
	import {getuserinfo} from "../../api/index.js";
	import {myBlanceLogList,myRoughlogList} from "../../api/store.js";
	export default {
		data() {
			return {
				inx: 1,
				page: 1,
				size: 10,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				fhtbList:[],
				FHList:[],
				identityAll:{},
				userinfo:{},
				memberAttach:{},
			}
		},
		onLoad() {
			this.initList()
			this.getuser()
		},
		methods: {
			// 用户信息
			getuser() {
				getuserinfo().then(res => {
					console.log(res)
					this.userinfo = res.data
					this.identityAll = res.data.identity
					this.memberAttach = res.data.member_attach
				})
			},
			// 初始化福和通宝收益列表
			initList() {
				let data = {
					page: this.page,
					size: this.size,
				};
				myBlanceLogList(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						let list = res.data.data;
						this.fhtbList = this.page == 1 ? list : this.fhtbList.concat(list);
						console.log(this.fhtbList);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
				})
			},
			// 初始化福和通宝收益列表
			initList2() {
				let data = {
					page: this.page,
					size: this.size,
				};
				myRoughlogList(data).then(res => {
					console.log(res);
					if (res.code == 1) {
						let list = res.data.data;
						this.FHList = this.page == 1 ? list : this.FHList.concat(list);
						console.log(this.FHList);
						if (list.length < this.size) this.status = 'nomore';
						else this.status = 'loading';
					}
				})
			},
			isCopy() {
				uni.setClipboardData({
					data: this.userinfo.eth_address,
					success: function() {
						uni.$u.toast('复制成功');
					}
				});
			},
			istaggle(e) {
				this.inx = e.currentTarget.dataset.type
				console.log(this.inx);
				this.page = 1
				if(this.inx == 1){
					this.initList()
				}else{
					this.initList2()
				}
			}
		},
		//触底加载
		onReachBottom() {
			console.log('触底加载');
			if (this.status != 'nomore') {
				this.page = this.page + 1
				if(this.inx == 1){
					this.initList()
				}else{
					this.initList2()
				}
			}
		}
	}
</script>
<style>
	page {
		background: #211E38;
	}
</style>
<style scoped>
	.user {
		width: 100%;
		margin-top: 50rpx;
	}

	.mart {
		margin-top: 50rpx;
	}

	.user_l {
		width: 20%;
	}

	.user_l>image {
		width: 100rpx;
		height: 100rpx;
		border-radius: 50%;
	}

	.user_c {
		width: 55%;
	}

	.user_c_name {
		margin-bottom: 10rpx;
	}

	.user_r {
		width: 25%;
	}

	.user_r>text {
		width: 156rpx;
		height: 56rpx;
		text-align: center;
		line-height: 56rpx;
		color: #663F0A;
		font-size: 26rpx;
		background: linear-gradient(270deg, #F2D89A 0%, #E3B863 100%);
		border-radius: 400rpx 400rpx 400rpx 400rpx;
	}

	.realName {
		width: 76rpx;
		height: 34rpx;
		line-height: 34rpx;
		text-align: center;
		border-radius: 6rpx;
		color: #ffffff;
		font-size: 20rpx;
		margin-left: 20rpx;
		background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
	}

	.nos {
		opacity: 0.5;
	}

	.blockchain {
		width: 690rpx;
		margin: 40rpx auto;
		overflow: hidden;
	}

	.blockchain_box {
		display: flex;
		align-items: center;
		width: 640rpx;
		font-weight: 400;
		font-size: 26rpx;
		color: #A6A5AF;
	}

	.blockchain_box>text:nth-child(1) {
		width: 24%;
	}

	.blockchain_box>text:nth-child(2) {
		width: 76%;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
		overflow: hidden;
	}

	.blockchain>image {
		width: 26rpx;
		height: 26rpx;
		margin-left: 10rpx;
	}


	.income_box {
		width: 690rpx;
		height: 96rpx;
		background: #35325D;
		border-radius: 18rpx;
		margin: 24rpx auto;
	}

	.income_box>text:nth-child(1) {
		width: 42%;
		color: #ffffff;
		font-size: 32rpx;
		margin-left: 30rpx;
	}

	.income_box>text:nth-child(2) {
		color: #E5CA9C;
		font-size: 36rpx;
	}



	.transaction_s {
		width: 92%;
		margin: 0rpx auto;
		font-size: 26rpx;
	}

	.recommendation {
		width: 100%;
		min-height: 800rpx;
		/* background: pink; */
		background: #1C1B31;
		border-radius: 56rpx 56rpx 0 0;
		margin-top: 230rpx;
	}

	.recommendation>text {
		color: #ffffff;
		font-size: 32rpx;
		margin: 48rpx 0 0 28rpx;
	}

	.navtab {
		width: 100%;
		color: #ffffff;
		padding: 20rpx 0;
		margin-top: 30rpx;
	}

	.active {
		position: relative;
		color: #ffffff;
	}

	.active::before {
		content: '';
		position: absolute;
		bottom: -14rpx;
		left: 50%;
		transform: translateX(-50%);
		height: 6rpx;
		width: 112rpx;
		border-radius: 40rpx;
		background: linear-gradient(279deg, #3040FC 1%, #FF2CDF 100%);
	}

	.income_list {
		width: 92%;
		margin: 20rpx auto 0;
		border-bottom: 1rpx solid #ffffff30;
	}

	.income_list_box {
		/* font-size: 28rpx; */
		color: #A6A5AF;
		margin: 20rpx 0;
	}




	/deep/ .u-navbar__content__right__text {
		color: #FFFFFF;
	}
</style>